home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / OBJECT.CH < prev    next >
Encoding:
Text File  |  1993-01-21  |  14.6 KB  |  266 lines

  1. //*****************************************************************************
  2. // OBJECT.CH
  3. // The CLIPPER OBJECTs HEADER v2.03
  4. // Copyright (c) 1991, JHK, JHK-Software, Piestany
  5. // Please compile files with this header with switches: /N/M/W/A
  6. //-----------------------------------------------------------------------------
  7.  
  8. //#define CLASSY     //CLASSY users can use this line...
  9.  
  10. #ifndef CLASSY
  11.   #ifndef OCLIP
  12.     #define OCLIP    //Default is the OCLIP object system...
  13.   #endif
  14. #endif
  15.  
  16.  
  17. //-------- language support ---------------------------------------------------
  18.  
  19. //#define SLOVAK     //can't be, this is a default!
  20. //#define  ENGLISH   //for english laguage support you must use this line!
  21.  
  22. //-------- modify for more readable source codes ------------------------------
  23.  
  24. #define and          .and.
  25. #define or           .or.
  26. #define true         .t.
  27. #define false        .f.
  28. #define cr_lf        (chr(13)+chr(10))
  29. #define NTrim(n)     LTrim(Str(n))
  30. #define Swap(a,b)    Eval({|p|p:=a,a:=b,b:=p})
  31. #define Bell()       Tone(400,0.2)
  32.  
  33. #xcommand Assert(<f>[,<t>]) => if(!(<f>), Abort("Assertion failed: "+<"f">[+", "+<t>]), )
  34.  
  35. #xtranslate (<var> IN <a>,<b>) => (<a> <= <var> .and. <var> <= <b>)
  36.  
  37.  
  38. //-------- Unconditional break exception --------------------------------------
  39.  
  40. #xcommand BEGIN BREAK => PushBreak(ErrorBlock({|o|DoBreak(o)})); begin sequence
  41.  
  42. #xcommand RECOVER BREAK [USING <var>] => recover [using <var>]; ErrorBlock(TopBreak())
  43.  
  44. #xcommand END BREAK => end; ErrorBlock(PopBreak())
  45.  
  46. #xcommand BREAKIF <lExpr> [WITH <obj>] => if <lExpr>; break [ <obj> ]; endif
  47.  
  48.  
  49. //-------- Standart Commands extension ----------------------------------------
  50.  
  51. #xtranslate ALERT(     => OAlert(
  52.  
  53. #xcommand ENDWHILE [<lExpr>] => [if <lExpr>; exit; end;] end
  54.  
  55. #xcommand REPEAT => while .t.
  56. #xcommand LOOPIF <lExpr> => if <lExpr>; loop; end
  57. #xcommand EXITIF <lExpr> => if <lExpr>; exit; end
  58. #xcommand UNTIL <lExpr>  => if <lExpr>; exit; end; end
  59. #xcommand ENDREPEAT => end
  60.  
  61. #xcommand RETURNIF <lexpr> [WITH <xvalue, ...>] => if <lexpr>; return [ <xvalue> ]; endif
  62. #xcommand RETURN <cur> UPDATE WITH <new> => return Eval( {|t| t:=<cur>, if(nil==<new>,nil,<cur>:=<new>), t})                                               //From Nantucket News, Vol.5, No.4, 1991 (author Mike Schinkel)
  63.  
  64. #xcommand FILL EMPTY <Var1> := <Value1>[, <VarN> := <ValueN>] => if(Empty(<Var1>), <Var1>:=<Value1>, nil)[; if(Empty(<VarN>), <VarN>:=<ValueN>, nil)]
  65. #xcommand FILL EMPTY <Var1> WITH <Value1>[, <VarN> WITH <ValueN>] => if(Empty(<Var1>), <Var1>:=<Value1>, nil)[; if(Empty(<VarN>), <VarN>:=<ValueN>, nil)]
  66.  
  67. #xcommand DEFAULT <Var1> := <Value1>[, <VarN> := <ValueN>] => if(nil==<Var1>, <Var1>:=<Value1>, nil)[; if(nil==<VarN>, <VarN>:=<ValueN>, nil)]             //From Nantucket News, Vol.5, No.4, 1991 (author Mike Schinkel)
  68. #xcommand DEFAULT <Var1> TO <Value1>[, <VarN> TO <ValueN>] => if(nil==<Var1>, <Var1>:=<Value1>, nil)[; if(nil==<VarN>, <VarN>:=<ValueN>, nil)]             //From Nantucket News, Vol.5, No.4, 1991 (author Mike Schinkel)
  69.  
  70. #xcommand STORE VALUE <Value1> INTO <Var1>[, <ValueN> INTO <VarN>] => if(nil<><Value1>, <Var1>:=<Value1>, nil)[; if(nil<><ValueN>, <VarN>:=<ValueN>, nil)]
  71.  
  72. #xcommand SET ERRORS FILE [TO] <FileName>  => SetErrFile( <(FileName)> )
  73. #xcommand SET LASTKEY [TO] <nkey> => SetLastKey(<nkey>)
  74. #xcommand SET QUICKESC [TO] <lValue> => SetQuickEsc(<lValue>)
  75. #xcommand SET DIALOG [TO] <lValue> => SetDialog(<lValue>)
  76. #xcommand CLEAR KEYBOARD => __Keyboard()
  77. #xcommand SKIP DELETED => SkipDeleted()
  78.  
  79. #xcommand REFRESH ROW => RefreshRow()
  80. #xcommand REFRESH TABLE => RefreshTable()
  81.  
  82.  
  83. #xcommand APPEND BLANK [IN <alias>[,<order>]] => ;
  84.     [SwapDatabase(<"alias">,<order>);] DbAppend() [; RestDatabase(<"alias">)]
  85.  
  86.  
  87. #xcommand DELETE [IN <alias>[,<order>]] [SEEK <key>] => ;
  88.     [SwapDatabase(<"alias">,<order>);] WEval( {||dbSeek(<key>),Found()}, {||dbDelete(),true} )[; RestDatabase(<"alias">)]
  89.  
  90. #xcommand DELETE [IN <alias>[,<order>]] [FOR <for>] [WHILE <while>] [NEXT <next>] [RECORD <rec>] [<rest:REST>] [ALL] => ;
  91.     [SwapDatabase(<"alias">,<order>);] DBEval( {||dbDelete()}, <{for}>, <{while}>, <next>, <rec>, <.rest.> )[; RestDatabase(<"alias">)]
  92.  
  93. #xcommand DELETE [IN <alias>[,<order>]] => ;
  94.     [SwapDatabase(<"alias">,<order>);] dbDelete() [; RestDatabase(<"alias">)]
  95.  
  96.  
  97. #xcommand RECALL [IN <alias>[,<order>]] [SEEK <key>] => ;
  98.     [SwapDatabase(<"alias">,<order>);] WEval( {||dbSeek(<key>),Found()}, {||dbRecall(),true} )[; RestDatabase(<"alias">)]
  99.  
  100. #xcommand RECALL [IN <alias>[,<order>]] [FOR <for>] [WHILE <while>] [NEXT <next>] [RECORD <rec>] [<rest:REST>] [ALL] => ;
  101.     [SwapDatabase(<"alias">,<order>);] DBEval( {||dbRecall()}, <{for}>, <{while}>, <next>, <rec>, <.rest.> )[; RestDatabase(<"alias">)]
  102.  
  103. #xcommand RECALL [IN <alias>[,<order>]] => ;
  104.     [SwapDatabase(<"alias">,<order>);] dbRecall() [; RestDatabase(<"alias">)]
  105.  
  106.  
  107. #xcommand REPLACE <f1>:=<v1>[, <fN>:=<vN>] [IN <alias>[,<order>]] [SEEK <key>] => ;
  108.     [SwapDatabase(<"alias">,<order>);] WEval( {||dbSeek(<key>),Found()}, {||_FIELD-><f1>:=<v1>[, _FIELD-><fN>:=<vN>], true})[; RestDatabase(<"alias">)]
  109.  
  110. #xcommand REPLACE <f1>:=<v1>[, <fN>:=<vN>] [IN <alias>[,<order>]] [FOR <for>] [WHILE <while>] [NEXT <next>] [RECORD <rec>] [<rest:REST>] [ALL] => ;
  111.     [SwapDatabase(<"alias">,<order>);] DBEval({|| _FIELD-><f1>:=<v1>[, _FIELD-><fN>:=<vN>]}, <{for}>, <{while}>, <next>, <rec>, <.rest.> )[; RestDatabase(<"alias">)]
  112.  
  113. #xcommand REPLACE <f1>:=<v1>[, <fN>:=<vN>] [IN <alias>[,<order>]] => ;
  114.     [SwapDatabase(<"alias">,<order>);] _FIELD-><f1>:=<v1>[; _FIELD-><fN>:=<vN>] [; RestDatabase(<"alias">)]
  115.  
  116.  
  117. //-------- NET Commands extension ---------------------------------------------
  118.  
  119. #xcommand NET CREATE <(file1)> [FROM <(file2)>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetCreateFrom(<(file1)>,<(file2)>,<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  120.  
  121. #xcommand NET USE => DbCloseArea()
  122.  
  123. #xcommand NET USE <(db)> [VIA <rdd>] [ALIAS <a>] [<new:NEW>] [<ex:EXCLUSIVE>] [<sh:SHARED>] [<ro:READONLY>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  124.     NetDbUseArea(<.new.>, <rdd>, <(db)>, <(a)>, if(<.sh.>.or.<.ex.>, !<.ex.>, nil), <.ro.>, <.cont.>.or.<.ret.> ) [; if neterr(); return <expr>; end]
  125.  
  126. #xcommand NET USE <(db)> [VIA <rdd>] [ALIAS <a>] [<new:NEW>] [<ex:EXCLUSIVE>] [<sh:SHARED>] [<ro:READONLY>] INDEX <list, ...> [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  127.     NetDbUseArea(<.new.>, <rdd>, <(db)>, <(a)>, if(<.sh.>.or.<.ex.>, !<.ex.>, nil), <.ro.>, <.cont.>.or.<.ret.> ) [; if neterr(); return <expr>; end];
  128.     if !NetErr(); NetSetIndex(#<list>,<.cont.>.or.<.ret.>); [if neterr(); return <expr>; end;] end
  129.  
  130. #xcommand NET INDEX ON <key> TO <(file)> [<uni:UNIQUE>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetIndexOn(<(file)>,<"key">,<{key}>,if(<.uni.>,.t.,nil),<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  131.  
  132. #xcommand NET SET INDEX TO => set index to
  133. #xcommand NET SET INDEX TO <(i1)>[,<(iN)>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  134.     NetSetIndex(<(i1)>[+","+<(iN)>],<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  135.  
  136.  
  137. #xcommand NET APPEND BLANK [IN <alias>[,<order>]] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  138.     [SwapDatabase(<"alias">,<order>);] NetDbAppend(<.cont.>.or.<.ret.>) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  139.  
  140.  
  141. #xcommand NET DELETE [IN <alias>[,<order>]] [SEEK <key>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  142.     [SwapDatabase(<"alias">,<order>);] WEval( {||dbSeek(<key>),Found()}, {||NetDbDelete(<.cont.>.or.<.ret.>)} )[; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  143.  
  144. #xcommand NET DELETE [IN <alias>[,<order>]] [FOR <for>] [WHILE <while>] [NEXT <next>] [RECORD <rec>] [<rest:REST>] [ALL] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  145.     [SwapDatabase(<"alias">,<order>);] DbEval( {|| NetDbDelete(<.cont.>.or.<.ret.>)}, <{for}>, <{while}>, <next>, <rec>, <.rest.> ) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  146.  
  147. #xcommand NET DELETE [IN <alias>[,<order>]] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  148.     [SwapDatabase(<"alias">,<order>);] NetDbDelete(<.cont.>.or.<.ret.>) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  149.  
  150.  
  151. #xcommand NET RECALL [IN <alias>[,<order>]] [SEEK <key>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  152.     [SwapDatabase(<"alias">,<order>);] WEval( {||dbSeek(<key>),Found()}, {||NetDbRecall(<.cont.>.or.<.ret.>)} )[; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  153.  
  154. #xcommand NET RECALL [IN <alias>[,<order>]] [FOR <for>] [WHILE <while>] [NEXT <next>] [RECORD <rec>] [<rest:REST>] [ALL] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  155.     [SwapDatabase(<"alias">,<order>);] DbEval( {|| NetDbRecall(<.cont.>.or.<.ret.>)}, <{for}>, <{while}>, <next>, <rec>, <.rest.> ) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  156.  
  157. #xcommand NET RECALL [IN <alias>[,<order>]] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  158.     [SwapDatabase(<"alias">,<order>);] NetDbRecall(<.cont.>.or.<.ret.>) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  159.  
  160.  
  161. #xcommand NET REPLACE <f1>:=<v1>[, <fN>:=<vN>] [IN <alias>[,<order>]] [SEEK <key>] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  162.     [SwapDatabase(<"alias">,<order>);] WEval( {||dbSeek(<key>),Found()}, {||NetReplace({||_FIELD-><f1>:=<v1>[, _FIELD-><fN>:=<vN>]}, <.cont.>.or.<.ret.>)}) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  163.  
  164. #xcommand NET REPLACE <f1>:=<v1>[, <fN>:=<vN>] [IN <alias>[,<order>]] [FOR <for>] [WHILE <while>] [NEXT <next>] [RECORD <rec>] [<rest:REST>] [ALL] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  165.     [SwapDatabase(<"alias">,<order>);] DBEval({|| NetReplace({||_FIELD-><f1>:=<v1>[, _FIELD-><fN>:=<vN>]}, <.cont.>.or.<.ret.>) }, <{for}>, <{while}>, <next>, <rec>, <.rest.> )[; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  166.  
  167. #xcommand NET REPLACE <f1>:=<v1>[, <fN>:=<vN>] [IN <alias>[,<order>]] [<cont:CONTINUE>] [<ret:RETURN> <expr>] => ;
  168.     [SwapDatabase(<"alias">,<order>);] NetReplace({||_FIELD-><f1>:=<v1>[, _FIELD-><fN>:=<vN>]}, <.cont.>.or.<.ret.>) [; RestDatabase(<"alias">)] [; if neterr(); return <expr>; end]
  169.  
  170.  
  171. #xcommand NET RLOCK [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetRLock(<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  172.  
  173. #xcommand NET FLOCK [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetFLock(<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  174.  
  175. #xcommand NET ERASE <(file)> [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetFErase(<(file)>,<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  176.  
  177. #xcommand NET REINDEX [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetReIndex(<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  178.  
  179. #xcommand NET PACK [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetPack(<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  180.  
  181. #xcommand NET ZAP [<cont:CONTINUE>] [<ret:RETURN> <expr>] => NetZap(<.cont.>.or.<.ret.>) [; if neterr(); return <expr>; end]
  182.  
  183. #xcommand NET UNLOCK [<rest>] => commit; unlock [<rest>]
  184.  
  185. #xcommand NET CLOSE [<rest>] => net unlock [<rest>] ; close [<rest>]
  186.  
  187.  
  188. //-------- Object oriented support! -------------------------------------------
  189.  
  190. #xtranslate OBJECT [<Obj>] OF <Class> => [<Obj>:=]<Class>():New()
  191. #xtranslate OBJECT <Obj> OF <Class> INIT => <Obj>:=<Class>():New(); <Obj>:Init()
  192. #xtranslate OBJECT <Obj> OF <Class> INIT <*Tail*> => <Obj>:=<Class>():New(); <Obj>:Init(); (<Tail>)
  193.  
  194. #ifdef CLASSY
  195.   #include "Class(y).ch"
  196.   #xtranslate :SUPER([<class>]):  => :super:
  197.   #xcommand METHOD NEW=<*tail*> =>
  198.   #xcommand CONSTRUCTOR <ctor>() => ;
  199.     static function New();;
  200.     local __csyDummy:=qself():super:New();;
  201.     local self:=qself()
  202. #else
  203.   #include "OClip.ch"
  204. #endif
  205.  
  206.  
  207. //-------- Color access -------------------------------------------------------
  208.  
  209. #define nNormal    1   //CLIPPER:Normal,Enhanced,Border,NotUse,Unselect
  210. #define nEnhanced  2
  211. #define nBorder    3
  212. #define nNotUse    4
  213. #define nUnSelect  5
  214.  
  215. #define nShadow    3   //WINDOW: Normal,Enhanced,Shadow,Title, Unselect
  216. #define nTitle     4
  217.  
  218. #define nSelected  2   //MENU:   Normal,Selected,Shadow,Letter,Disable
  219. #define nLetter    4
  220. #define nDisable   5
  221. #define nExtension 6
  222.  
  223.  
  224. //-------- Various constants for Object.lib -----------------------------------
  225.  
  226. #define DISABLE         "__DISABLE"
  227. #define DisableHelp()   ReadHelpVar(DISABLE)
  228. #define EnableHelp()    ReadHelpVar("")
  229.  
  230. #define OD_SCREEN   "1"   //output device for function OutputDevice(dev)
  231. #define OD_PRINTER  "2"   //output device for function OutputDevice(dev)
  232.                           //can be also: FullPathAndFileName
  233.  
  234. #define cTempFile     "SysTmp$$"      //temporary dbf,ntx  see c_Dbf.prg, c_Report.prg
  235. #define cErrFile      "SysError.txt"  //see Object1.prg
  236. #define cBasic        "System1"       //ƒø                         //paswords
  237. #define cIFR          "System2"       //ƒ≈ƒ> Object.lib databases  //indexes, filters, reports
  238. #define cHelp         "System3"       //ƒŸ                         //help
  239. #define cNtxFile      "SysN"          //SysN9999.ntx               //9999 number defined inside View`InsIndex()   //LEGTH OF STRING cNtxFile MUST BE 4 CHARs!!!
  240. #define cRptFile      "SysR"          //SysR9999.txt               //9999 number defined inside Report`VProcess() //LEGTH OF STRING cRptFile MUST BE 4 CHARs!!!
  241.  
  242. #define nNetWaitSec    1              //Object1.prg
  243. #define nVPaintWaitSec 2              //Browse.prg
  244.  
  245. #define nLenPsw        20             //length of user_id and password
  246. #define nMinMemory     40             //for running archivation (in kB)
  247.  
  248. #define nLenIFRName    30             //length of name for Index/Filter/Report menu item
  249. #define nLenColTitle   15             //max length of column title of report
  250. #define nLenTopBottom  58             //width of edit window for insert Top and Bottom text of report
  251. #define nLenIFRData    250            //length of Data item in file cIFR (see C_DBF.prg->CreateBasic1() too)
  252. #define nMaxPrintCols  512            //max. width of report in columns
  253.  
  254. #define nSwapTask      255            //keyboard_code: force exit for all windows applications (need for task switching)
  255. #define nWaitForKey    254            //keyboard_code: need for ShowTime() in AChoice and MemoEdit().
  256.  
  257. #define nLongName      1              //ƒø
  258. #define nShortName     2              // √ƒ> used as array indexes into Get:Cargo[]
  259. #define nAlias         3              // ≥
  260. #define nRowOffset     4              // ≥   (for Browse:FormActive, need for setting Get:Row in Mask() class)
  261. #define nColOffset     5              //ƒŸ   (for Browse:FormActive, need for setting Get:Col)
  262. #define nLenCargo      5              // length of Get:Cargo[] array
  263.  
  264. //-------------------------------------------------- eof (c)JHK ---------------
  265.  
  266.